package com.didispace.domain;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author zrhong
 * @version 1.0
 * @date 2018/6/21 22:05
 * @description
 */
@Service
public class UserService {
    @Autowired
    private UserRepository userRepository;
    @Cacheable(value = "users", key = "#name")
    public User findByName(String name){
        return userRepository.findByName(name);
    }

    @CacheEvict(value = "users", allEntries = true)
    public User save(User user){
        return userRepository.save(user);
    }
}
